package ro.sergiu.configmanager.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * ConfigSource will keep informations about the source and the behavior in case
 * of errors
 *
 * @author Toporjinschi
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ConfigSource {

    /**
     * The location for saving settings; ${val} will be replaced with values
     * which can be found in {@link System#getProperty(java.lang.String)}; If
     * the value could not be found then the placeholder will be removed
     *
     * @return
     */
    String value();

    /**
     * Type of source; type {@link ConfigSourceType}, if type is FILE then value
     * needs to be a path to a property file;<br/>
     * By default, type is {@link ConfigSourceType#FILE}
     *
     * @return the type of source;
     */
    ConfigSourceType type() default ConfigSourceType.FILE;

    /**
     * Dictates the behavior in case of an unreadable file;<br/> If is set on
     * {@link ErrorBehaviorType#LOAD_DEFAULT} then the object will only be
     * instantiated;<br/>
     * If {@link ErrorBehaviorType#THROW_ERROR} an error will be thrown;<br/>
     * By default, errorBehavior is set on
     * {@link ErrorBehaviorType#LOAD_DEFAULT}
     *
     * @return the error behavior;
     */
    ErrorBehaviorType errorBehavior() default ErrorBehaviorType.LOAD_DEFAULT;
}
